package com.wondedDream.controller.web;

import com.wondedDream.jwt.annotation.JwtTokenRequired;
import com.wondedDream.model.PracticeQuestion;
import com.wondedDream.service.PracticeQuestionService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController(value = "webPracticeQuestionController")
@RequestMapping("/web/practiceQuestions")
@Api(description = "客户端-用户练习习题模块")
public class UserPracticeQuestionController {

    @Autowired
    private PracticeQuestionService practiceQuestionService;

    // 获取练习问题信息
    @GetMapping("/{id}")
    @JwtTokenRequired
    public PracticeQuestion getPracticeQuestionById(@PathVariable(name = "id") Integer id) {
        return practiceQuestionService.getPracticeQuestionById(id);
    }

    // 获取某一课程下的练习问题列表
    @GetMapping("/byPractice/{practiceId}")
    public List<PracticeQuestion> getPracticeQuestionsByPracticeId(@PathVariable Integer practiceId) {
        return practiceQuestionService.getPracticeQuestionsByPracticeId(practiceId);
    }
}